home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / pxewin.zip / PXLISTBX.CPP < prev    next >
Text File  |  1992-02-27  |  7KB  |  266 lines

  1. // PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
  2.  
  3. // PXLISTBX.CPP //
  4.  
  5. // Contents ----------------------------------------------------------------
  6. //
  7. //    This module contains members for the PXListBox class.
  8. //
  9. // End ---------------------------------------------------------------------
  10.  
  11. // External Reference Name for this Header ---------------------------------
  12.  
  13. #ifndef PXLISTBX_CPP
  14.     #define PXLISTBX_CPP
  15.  
  16. // End ---------------------------------------------------------------------
  17.  
  18. // Interface Dependencies --------------------------------------------------
  19.  
  20. #ifndef PXLISTBX_HPP
  21.     #include "pxlistbx.hpp"
  22. #endif // PXLISTBX_HPP //
  23.  
  24. // End ---------------------------------------------------------------------
  25.  
  26. // constructor PXListBox //
  27.  
  28. inline PXListBox::PXListBox(PBrowser AParent,
  29.     int AnId,int X,int Y,int W,int H,
  30.     PTModule AModule):
  31.     TListBox((PTWindowsObject)AParent,
  32.     AnId,X,Y,W,H,AModule)
  33. {
  34.     BOOL temp;
  35.  
  36.     // Copy display pointer and scroller
  37.  
  38.     my_display = AParent->my_display;
  39.     my_parent = AParent;
  40.  
  41.     // Disable item sort.
  42.  
  43.     Attr.Style &= ~LBS_SORT;
  44. }
  45.  
  46. // Summary -----------------------------------------------------------------
  47. //
  48. //    Redefines and sets up list boxes for the browser display.
  49. //
  50. // Parameters
  51. //
  52. //    Parameters are as they are ussually for list boxes except the
  53. //    parent window is of type Browser.  This must be caste to a
  54. //    PTWindowsObject type.
  55. //
  56. // Functional Description
  57. //
  58. //    Caste the parent window to my display object so we can call display
  59. //    routines.  Set the style so that the list boxes are not sorted.
  60. //
  61. // End ---------------------------------------------------------------------
  62.  
  63. // member build of PXListBox //
  64.  
  65. PTStreamable PXListBox::build()
  66. {
  67.     return new PXListBox(streamableInit);
  68. }
  69.  
  70. TStreamableClass RegPXListBox("PXListBox",PXListBox::build,
  71.     __DELTA(PXListBox));
  72.  
  73. // Description -------------------------------------------------------------
  74. //
  75. //    When the streamable constructor is called, TStreamable dispatches
  76. //    the build member to construct the object.  To do this, it must
  77. //    know where to find this member functions for the specific class.
  78. //    This is the reason for the stream registration.
  79. //
  80. // End ---------------------------------------------------------------------
  81.  
  82. // member read of PXListBox //
  83.  
  84. inline Pvoid PXListBox::read(Ripstream is)
  85. {
  86.     TListBox::read(is);
  87.     return this;
  88. }
  89.  
  90. // Summary -----------------------------------------------------------------
  91. //
  92. //    Call TListBox read member.
  93. //
  94. // End ---------------------------------------------------------------------
  95.  
  96. // member write of PXListBox //
  97.  
  98. inline void PXListBox::write(Ropstream os)
  99. {
  100.     TListBox::write(os);
  101. }
  102.  
  103. // Summary -----------------------------------------------------------------
  104. //
  105. //    Call TListBox write member.
  106. //
  107. // End ---------------------------------------------------------------------
  108.  
  109. // member LBNSelChange of PXListBox //
  110.  
  111. inline void PXListBox::LBNSelChange(RTMessage)
  112. {
  113.     my_display->SelRecord(GetSelIndex());
  114.  
  115.     // Set the scroller to the correct position
  116.  
  117.     my_parent->SetScroller();
  118. }
  119.  
  120. // Summary -----------------------------------------------------------------
  121. //
  122. //    Responds to a mouse click selection in a list box.  The selection is
  123. //    dispatched to the display routines SelRecord member to select the
  124. //    record cooresponding to the selection.
  125. //
  126. // End ---------------------------------------------------------------------
  127.  
  128. // member WMPaint of PXListBox //
  129.  
  130. inline void PXListBox::WMPaint(RTMessage Msg)
  131. {
  132.     if(my_display->RetFlag())
  133.         TControl::WMPaint(Msg);
  134. }
  135.  
  136. // Description -------------------------------------------------------------
  137. //
  138. // Redefine WMPaint so that list boxes are not drawn when the
  139. // the Update flag is reset.  Since the OWL will do screen refresh
  140. // on the list boxes for each new entrie in the box, it is better
  141. // to do a paint after the list has completely been updated.
  142. //
  143. // End ---------------------------------------------------------------------
  144.  
  145. // member DefWndProc of PXListBox //
  146.  
  147. void PXListBox::DefWndProc(RTMessage Msg)
  148. {
  149.     BOOL my_key = FALSE;                    /* Indicates if key has been
  150.                            process before DefWndProc
  151.                         */
  152.  
  153.     // We will need to repond to some keystrokes and exclude their
  154.     // processing from the defualt DefWndProc.
  155.  
  156.     if(Msg.Message == WM_KEYDOWN)
  157.     {
  158.         switch(Msg.WParam)
  159.         {
  160.             // Cursor down
  161.  
  162.             case VK_DOWN:
  163.             {
  164.                 if(GetSelIndex() == PAGE_SIZE - 1)
  165.                 {
  166.                     my_display->SelRecord(GetSelIndex());
  167.                     my_key = TRUE;
  168.                 }
  169.                 break;
  170.             }
  171.  
  172.             // Cursor up
  173.  
  174.             case VK_UP:
  175.             {
  176.                 if(GetSelIndex() == 0)
  177.                 {
  178.                     my_display->SelRecord(GetSelIndex());
  179.                     my_key = TRUE;
  180.                 }
  181.                 break;
  182.             }
  183.  
  184.             // Deactivate cursor left and right
  185.  
  186.             case VK_LEFT:
  187.             {
  188.                 my_key = TRUE;
  189.                 break;
  190.             }
  191.             case VK_RIGHT:
  192.             {
  193.                 my_key = TRUE;
  194.                 break;
  195.             }
  196.  
  197.             // Page Down
  198.  
  199.             case VK_NEXT:
  200.             {
  201.                 my_display->FillBoxes(my_display->top_rec
  202.                     + PAGE_SIZE);
  203.                 my_key = TRUE;
  204.                 break;
  205.             }
  206.  
  207.             // Page Up
  208.  
  209.             case VK_PRIOR:
  210.             {
  211.                 my_display->FillBoxes(my_display->top_rec
  212.                     - PAGE_SIZE);
  213.                 my_key = TRUE;
  214.                 break;
  215.             }
  216.         }
  217.  
  218.         // Set the scroller to the current position
  219.  
  220.         my_parent->SetScroller();
  221.     }
  222.  
  223.     // If it's not one of the keys above then go ahead and call the
  224.     // normal windows procedure.
  225.  
  226.     if(my_key == FALSE)
  227.         TWindowsObject::DefWndProc(Msg);
  228. }
  229.  
  230. // Summary -----------------------------------------------------------------
  231. //
  232. //    Redefines DefWndProc to include special handling of cursor and
  233. //    page keys.
  234. //
  235. // Parameter
  236. //
  237. //    Msg.  This will be a reference to the message structure.
  238. //
  239. // Description
  240. //
  241. //      The cursor up and down keys will normally cause a windows selection
  242. //    change message to be sent so the LBNSelChange member will respond to
  243. //    these changes.  However, if the selection is the first or last item
  244. //    in the list and you press cursor up or down respectively, you will
  245. //    not get a selection change message.  These conditions need special
  246. //    handling.  The display SelRecord member is called in either case and
  247. //    the my_key flag is set to keep the default DefWndProc from
  248. //    reprocessing this condition.
  249. //
  250. //    PgUp and PgDwn key strokes, will only cause the item selection to
  251. //    go to the top or the bottom of the list.  These most be redefined
  252. //    to go up or down by the page width in the database.  This is done
  253. //    by calling the FillBoxes member of the display routine.  Again, the
  254. //    my_key flag is set to keep the normal DefWndProc from reprocessing
  255. //    these conditions.
  256. //
  257. //    The left and right cursor keys will act like the up and down cursor
  258. //    key normally.  They have been dispabled for simplicity.
  259. //
  260. //     If none of the above conditions occur, then the normal DefWndProc is
  261. //    called.
  262. //
  263. // End ---------------------------------------------------------------------
  264.  
  265. #endif // PXLISTBX_CPP //
  266.